#删除原容器
echo "begin stop and delete old blog-app......"
docker stop blog-app-cqj && docker rm blog-app-cqj
echo "=======================rm over=============================="

# build images
echo "=======================start build ddns images=============================="
docker build -t blog-app-cqj:1.0 sara-admin-java/docker/.
echo "build blog-app-cqj app success..."

# check path
blog_app_log_path="/home/docker/sara-blog/app/logs"
blog_app_resources_path="/home/docker/sara-blog/app/sara-resources"
if [[ ! -d "blog_app_log_path" ]]; then
    echo "blog_app_log_path not exsits,create now."
    mkdir -p ${blog_app_log_path}
else
    echo "blog_app_log_path exsits,do not create."
fi
if [[ ! -d "blog_app_resources_path" ]]; then
    echo "blog_app_resources_path not exsits,create now."
    mkdir -p ${blog_app_resources_path}
else
    echo "blog_app_resources_path exsits,do not create."
fi

#build new ddns container
echo "=======================start build blog-app-cqj container=============================="
docker run -d \
--ip 172.20.1.12 \
--network=bridge-chen \
-v /home/docker/sara-blog/app/logs:/home/docker/sara-blog/app/logs \
-v /home/docker/sara-blog/app/sara-resources:/home/docker/sara-blog/app/resource/sara-resources \
--privileged=true \
--name blog-app-cqj \
--restart=always \
blog-app-cqj:1.0
echo "=======================build end.=============================="
